<template>
	<view class="global">
		<view class="video">
<video :src="playURL" style="width:100%"></video>
		</view>
		<view class="">
			课程目录
		</view>
		<uni-collapse>
			<uni-collapse-item v-for="item in obj.chapterList" :title="item.title">
				<view @click="getsp(item2)" class="" style="height: 40px;line-height: 40px" v-for="item2 in item.children">
					{{item2.title}}
		
				</view>
			</uni-collapse-item>
		
		</uni-collapse>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app';
import { ref } from 'vue';
	import instance from '../../request';
	const obj=ref({});
	const playURL=ref("");
	onLoad(e => {
		console.log(e)
		getdetail(e)
	})
	const getdetail  =async (e) => {
		const res = await instance.get(`/api/edu/course/${e.id}`);
		console.log(res)
		obj.value=res.data
		console.log(obj.value.chapterList[0].children[0].id)
		getsp(obj.value.chapterList[0].children[0].id);
		
	}
	const getsp=async(e)=>{
		
		const res=await instance.get(`/api/vod/video/getPlayURL/${e.id}`);
		console.log(res)
		playURL.value=res.data.playURL
	}
</script>

<style>
	.video {
		width: 100%;
		height: 225px;

	}

	page {
		width: 100%;
		height: 100%;
	}

	.global {
		width: 100%;
		height: 100%;

	}
</style>